import 'package:flutter/material.dart';
import 'package:wheel_of_fortune/model/user_address_model.dart';
import 'package:wheel_of_fortune/utils/utils.dart';


class AddressItem extends StatelessWidget {
  final onSelect;
  final onEdit;
  final UserAddressModel model;
  /// 0-Registered Address  1-Delivery Address
  final type;
  const AddressItem({this.onSelect,this.onEdit,this.model,this.type,Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    String text1 = '';
    String text2 = '';
    if (type == 0) {
      text1 = '${model.user['userName']} ${model.user['phone']}';
      text2 = '${model.user['address']} ${model.user['cityName']} ${model.user['provinceName']}';
    } else {
      text1 = '${model.address} ${model.cityName} ${model.provinceName}';
      text2 = '${model.address} ${model.cityName} ${model.provinceName}';
    }
    return Container(
      margin: EdgeInsets.only(bottom: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(9.0)
      ),
      child: Container(
        padding: EdgeInsets.only(bottom: 10, top: 15, left: 15, right: 10),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            GestureDetector(
              onTap: this.onSelect,
              child: Image.asset('assets/images/${model.selectAddress?'Radiobutton_02.png':'Radiobutton_01.png'}',width: 16,height: 16,),
            ),
            SizedBox(width: 15,),
            Expanded(
              child: InkWell(
                onTap: type != 0?this.onEdit:null,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      this.type==0?'Registered Address':'Delivery Address',
                      style: TextStyle(
                        color: Color(0xFF052160),
                        fontFamily: 'Avenir Next LT Pro',
                        fontSize: 11.0,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    SizedBox(height: 5,),
                    Text(
                      text1,
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                        color: grey6EColor,
                        fontFamily: 'Avenir Next LT Pro',
                        fontSize: 10.0,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                    SizedBox(height: 3,),
                    Text(
                      text2,
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                        color: grey6EColor,
                        fontFamily: 'Avenir Next LT Pro',
                        fontSize: 10.0,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ],
                ),
              ),
            ),
            SizedBox(width: 10,),
            GestureDetector(
              onTap: type != 0?this.onEdit:null,
              child: Padding(
                padding: EdgeInsets.only(top: 25, bottom: 25),
                child: Center(child: Icon(Icons.arrow_forward_ios,size: 13,color: Color(0xFF888888),),),
              ),
            ),
          ],
        ),
      ),
    );
  }
}